<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>object_test2 Example</title>
</head>
<body>
<script>
function Score(mid, kor, eng){
	this.mid = mid;
	this.kor = kor;
	this.eng = eng;
	this.tot=0;
	this.avg=0;
	this.compute = function(){
		this.tot = this.kor + this.eng;
		this.avg = this.tot/2;
	}
	/*tot와 avg에 해당하는 getter생성*/
	this.getTot=function(){return this.tot;}
	this.getAvg=function(){return this.avg;}	
}

var array = new Array();
var s1 = new Score('kim',90,50);
var s2 = new Score('cho',60,70);

s1.compute();
s2.compute();

array.push(s1);
array.push(s2);

for(a=0; a<array.length;a++){
	document.write(array[a].mid+"<br/>");
	document.write(array[a].getTot() + "<br/>");
	document.write(array[a].getAvg() + "<br/>");
}

</script>
</body>
</html>